/**
 * 
 */
package code;

import java.io.File;

/**
 * @author Adam
 */
public class Photos {

	File		rootDirectory;
	IPhotoAlbum	rootAlbum;

	// Constructor ------------------------------------------------------------

	public Photos() {
	}

	public Photos(File rootDirectory) {
		setRoot(rootDirectory);
	}

	// Public Methods ---------------------------------------------------------

	public boolean collapseSubAlbums() {
		return rootAlbum.collapseAlbums();
	}

	public IPhotoAlbum getRootAlbum() {
		return rootAlbum;
	}

	public File getRoot() {
		return rootDirectory;
	}

	// Public Methods ---------------------------------------------------------

	/**
	 * Loads photos in the currently set directory. d1 d2 d3 Pa Pk Px Pb Pl Py Pc Pz
	 * 
	 * @return the number of loaded photos.
	 */
	public int loadPhotos() {
		if (rootAlbum == null)
			rootAlbum = new PhotoAlbum(rootDirectory);

		return rootAlbum.photosCountRecursive();
	}

	public void setRootAlbum(IPhotoAlbum rootAlbum) {
		this.rootAlbum = rootAlbum;
	}

	public void setRootDirectory(File rootDirectory) {
		this.rootDirectory = rootDirectory;
	}

	/**
	 * Set the root directory where you want the program to look photos. Call this if you want to change the root directory or set it if it
	 * hasn't already been set.
	 * 
	 * @param rootDirectory
	 */
	public void setRoot(File rootDirectory) {
		if (rootDirectory.isDirectory())
			this.rootDirectory = rootDirectory;
		else
			throw new ExceptionInInitializerError();
	}
}
